import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class h_6 {
    public static void main(String[] args) {
        int arr1[]=new int[]{1,2,3};
        int arr2[]=new int[]{3,4,5,2};
        ArrayList<Integer> list=new ArrayList<Integer>();

         /*ArrayList<Integer> list=new ArrayList<>();
        for(int i=0;i<arr1.length;i++){
            if(!list.contains(arr1[i])){
                list.add(arr1[i]);
            }
        }*/
        Arrays.stream(arr1).forEach(s->list.add(s));
        Arrays.stream(arr2).forEach(s->list.add(s));
        Object[] objects = list.stream().distinct().toArray();
        System.out.println(list);
        for (Object o:objects
             ) {
            System.out.println(o);
        }


       /* for(int i=0;i<arr2.length;i++){
            if(!list.contains(arr2[i])){
                list.add(arr2[i]);
            }
        }*/

    }
}
